<?php

require_once "db.php";

$realm_link_server = mysql_connect(OPENIDOO_DB_SERVER, OPENIDOO_DB_USER, OPENIDOO_DB_PASSWORD);
$realm_select_db = mysql_select_db(OPENIDOO_DB_DATABASE, $realm_link_server);
$openidoo_domain = str_replace('www.', '', $_SERVER['SERVER_NAME']);

if (!($check_realm = mysql_query("SELECT realm FROM openidoo_realm WHERE realm='".mysql_escape_string($openidoo_domain)."'"))) {
	die('Query failed.');
} else {

	if (mysql_num_rows($check_realm) > 0)
		define('OPENIDOO_DOMAIN', $openidoo_domain);
	else 
		exit('Domain not found');
}

session_start();

require 'functions.php';

?>
